#!/bin/bash

##################################################
#
#  @desc: sqoop数据抽取脚本-订单表-增量抽取
#  @auth: HUNTER.DUAN
#  @date: 2020-08-11
#  @param_1: 可传指定计算日期
#   
##################################################


export SQOOP_HOME=/opt/apps/sqoop-1.4.7

datestr=`date -d'-1 day' +%Y-%m-%d`

if [ $1 ]
then
datestr=$1
fi

${SQOOP_HOME}/bin/sqoop import \
--connect jdbc:mysql://doitedu01:3306/realtimedw \
--username root \
--password ABC123abc.123 \
--table oms_order \
--target-dir '/shelltest/oms_order'  \
--incremental lastmodified \
--check-column modify_time \
--last-value '${datestr} 23:59:59'  \
--fields-terminated-by ',' \
-m 1   \

if [ $? -eq 0 ]
then 
echo "execution succeed ,a mail has been sent ........."
else
echo "execution failed ,a mail has been sent ........."
fi
